<?php
namespace app\api\controller;
use think\Input;
use think\Controller;
use app\common\controller\Base;
use app\admin\model\Areas;
use app\admin\model\Pops;
class Pop extends Base{
	/*数据列表*/
	public function items($countryId=0,$cityId){
		$items = db('pops')->where(['city_id'=>$cityId,'area_id'=>$countryId,'status'=>1])->field('id,name,address')->select();
        if($items){
            return ['code'=>0,'msg'=>lang('success.'),'items'=>$items];
        }else{
            return ['code'=>-1,'msg'=>lang('Failed.')];
        }
	}
	/*获取pop地区*/
	public function countrys(){
		$countrys = Pops::getPOPCountrys();
		if($countrys){
			return ['code'=>0,'items'=>$countrys,'msg'=>'success'];
		}
		return ['code'=>-1,'msg'=>lang('Failed.')];
	}
	/*获取pop城市*/
	public function citys($countryId){
		$citys = Pops::getPOPCitys($countryId);
		if($citys){
			return ['code'=>0,'items'=>$citys,'msg'=>'success'];
		}
		return ['code'=>-1,'msg'=>lang('Failed.')];
	}
	public function one($popId){
		$item = db('pops')->where(['id'=>$popId])->find();
		if($item){
			return ['code'=>0,'data'=>$item,'msg'=>'success'];
		}
		return ['code'=>-1,'msg'=>lang('Failed.')];
	}

}